package com.dibang.app.operation.control.impl;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.EditText;

import com.dibang.app.R;
import com.dibang.app.mvp.abs.AbsControl;
import com.dibang.app.mvp.util.ISETUtil;
import com.dibang.app.operation.control.abs.LoginSmsMobileControl;
import com.dibang.app.operation.model.abs.LoginSmsMobileModel;
import com.dibang.app.operation.presenter.abs.LoginSmsMobilePresenter;
import com.dibang.app.operation.provider.LoginSmsMobileProImpl;
import com.dibang.app.operation.view.abs.LoginSmsMobileView;
import com.dibang.app.ui.LoginSmsActivity;
import com.dibang.app.view.AppKeyBoardUtil;
import com.dibang.app.view.ViewHelper;
import com.dx.dxloadingbutton.lib.LoadingButton;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by wxl on 2019/7/19.
 *
 */

public class LoginSmsMobileControlImpl extends AbsControl<LoginSmsMobileView,LoginSmsMobilePresenter,LoginSmsMobileModel,LoginSmsMobileProImpl> implements LoginSmsMobileControl{

    @BindView(R.id.sms_login_mobile_send_code_btn)
    LoadingButton sendCodeBtn;

    @BindView(R.id.sms_login_mobile_input_view)
    EditText mobileInputView;


    public LoginSmsMobileControlImpl(@NonNull View targetView) {
        super(targetView);
        ButterKnife.bind(this,targetView);
        ViewHelper.setLoadingButtonBackgroundShader(sendCodeBtn);
    }


    @OnClick(R.id.sms_login_mobile_send_code_btn)
    public void onSendCodeViewClick(View v){
        if(ISETUtil.get()
                .isNotEmpty(mobileInputView,"请输入手机号")
                .isMobile(mobileInputView,"请输入正确的手机号")
                .is()) {
            AppKeyBoardUtil.hideKeybord(mobileInputView);
            getContext().startActivity(new Intent(getContext(), LoginSmsActivity.class)
                    .putExtra("mobile",mobileInputView.getText().toString()));
        }
    }



    @Override
    public void onDestroy() {
        AppKeyBoardUtil.hideKeybord(mobileInputView);
        super.onDestroy();
    }
}
